from datetime import date
from pydantic import BaseModel, Field, ConfigDict
from typing import Optional, Literal
from pydantic.alias_generators import to_camel
from module_admin.annotation.pydantic_annotation import as_query
from datetime import datetime, date


class AttendanceModel(BaseModel):
    """
    考勤表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='考勤ID')
    employee_id: Optional[int] = Field(default=None, description='员工ID')
    attendance_date: Optional[date] = Field(default=None, description='考勤日期')
    status: Optional[Literal[0, 1, 2, 3]] = Field(default=None, description='状态: 0=出勤, 1=休假, 2=事假, 3=矿工')
    hours_worked: Optional[float] = Field(default=0.0, description='工作小时数')
    del_flag: Optional[Literal['0', '2']] = Field(default='0', description='删除标志（0代表存在 2代表删除）')
    create_by: Optional[str] = Field(default=None, description='创建者')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_by: Optional[str] = Field(default=None, description='更新者')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')
    employee_name: Optional[str] = Field(default=None, description='员工姓名')


@as_query
class AttendanceQueryModel(AttendanceModel):
    """
    考勤管理不分页查询模型
    """
    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数') 